SuperStrict

rem
bbdoc: SEDM.std
endrem
Module sedm.std

ModuleInfo "Name: sedm.std"
ModuleInfo "Description: small Vector Module"
ModuleInfo "Licence: MIT"
ModuleInfo "Author: Jens [bruZard] Henschel"

rem
	bbdoc: 3D Vector Class
end rem
Type bVector3
	Field x:Float
	Field y:Float
	Field z:Float
	
rem
bbdoc: creates a new bVector3 with the given values
endrem
	Function Create:bVector3(x:Float, y:Float, z:Float)
		Local vec:bVector3 = New bVector3
		vec.x	= x
		vec.y	= y
		vec.z	= z
		
		Return vec
	End Function
	
rem
bbdoc: creates a new Null Vector (0.0, 0.0, 0.0)
endrem
	Function NullVec:bVector3()
		Return bVector3.Create(0.0, 0.0, 0.0)
	End Function
	
rem
bbdoc: creates a 3D Vector from Pointer
endrem
	Function fromC:bVector3(vector:Byte ptr)
		Local vec:bVector3 = bVector3.NullVec()
		vec.x	= Float ptr(vector)[0]
		vec.y	= Float ptr(vector)[1]
		vec.z	= Float ptr(vector)[2]
		
		Return vec
	End Function
	
rem
bbdoc: returns a Pointer to a bVector3 Object
endrem
	Method toC:Byte ptr()
		Return VarPtr(Self.x)
	End Method
	
rem
bbdoc: returns a PositionObject
endrem
	Function createPosition:bVector3(x:Float, y:Float, z:Float)
		Return bVector3.Create(x, y, z)
	End Function
	
rem
bbdoc: returns a SizeObject
endrem
	Function createSize:bVector3(width:Float, Height:Float, depth:Float)
		Return bVector3.Create(width, Height, depth)
	End Function
	
rem
bbdoc: returns a RotationObject
endrem
	Function createRotation:bVector3(pitch:Float, yaw:Float, roll:Float)
		Return bVector3.Create(pitch, yaw, roll)
	End Function
	
rem
bbdoc: returns the x-component of this vector
endrem
	Method getX:Float()
		Return Self.x
	End Method
	
rem
bbdoc: returns the y-component of this vector
endrem
	Method getY:Float()
		Return Self.y
	End Method
	
rem
bbdoc: returns the z-component of this vector
endrem
	Method getZ:Float()
		Return Self.z
	End Method
EndType

Type bQuaternion
	Field w:Float
	Field X:Float
	Field Y:Float
	Field Z:Float
		
	Function Create:bQuaternion(x:Float, y:Float, z:Float, w:Float)
		Local q:bQuaternion = New bQuaternion
		q.x = x
		q.y = y
		q.z = z
		q.w = w
		
		Return q
	End Function
	
	Function fromC:bQuaternion(p:Byte ptr)
		Local q:bQuaternion = bQuaternion.NullVec()
		q.w = Float ptr(p)[0];
		q.x = Float ptr(p)[1];
		q.y = Float ptr(p)[2];
		q.z = Float ptr(p)[3];
		
		Return q
	End Function
	
	Function NullVec:bQuaternion()
		Return bQuaternion.Create(0.0, 0.0, 0.0, 0.0)
	End Function
	
	Method toC:Byte ptr()
		Return VarPtr(Self.w)
	End Method
End Type
